package com.xpqh.ai;

import com.xpqh.ai.dto.CozeRequest;
import com.xpqh.ai.dto.CozeResponse;
import com.xpqh.ai.service.CozeService;

/**
 * 扣子API测试类
 */
public class CozeApiTest {
    
    public static void main(String[] args) {
        // 创建服务实例
        CozeService cozeService = new CozeService();
        
        // 创建请求参数
        CozeRequest request = new CozeRequest();
        request.setImage_url("https://oss.h-ksg.com/system/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20250628144130.jpg");
        request.setPrompt("车辆颜色改为冰莓粉，只修改车辆颜色，保留车辆细节，多生成几张供客户选择");
        
        System.out.println("=== 扣子API调用测试 ===");
        System.out.println("请求参数:");
        System.out.println("  图片URL: " + request.getImage_url());
        System.out.println("  提示词: " + request.getPrompt());
        System.out.println();
        
        // 调用API
        System.out.println("正在调用扣子API...");
        CozeResponse response = cozeService.processImage(request);
        
        // 输出结果
        System.out.println("=== 响应结果 ===");
        System.out.println("节点类型: " + response.getNode_type());
        System.out.println("节点标题: " + response.getNode_title());
        System.out.println("是否完成: " + response.getNode_is_finish());
        System.out.println("内容类型: " + response.getContent_type());
        System.out.println("Token消耗: " + response.getToken());
        System.out.println("成本: " + response.getCost());
        System.out.println();
        
        // 输出原始内容
        System.out.println("原始响应内容:");
        System.out.println(response.getContent());
        System.out.println();
        
        // 如果有解析后的数据，输出详细信息
        if (response.getContentData() != null && response.getContentData().getOutput() != null) {
            CozeResponse.OutputData output = response.getContentData().getOutput();
            System.out.println("解析后的数据:");
            System.out.println("  状态码: " + output.getCode());
            System.out.println("  消息: " + output.getMessage());
            System.out.println("  耗时: " + output.getTime_elapsed());
            
            if (output.getData() != null) {
                CozeResponse.DataInfo data = output.getData();
                System.out.println("  VLM结果: " + data.getVlm_result());
                
                if (data.getImage_urls() != null && !data.getImage_urls().isEmpty()) {
                    System.out.println("  生成的图片URLs:");
                    for (int i = 0; i < data.getImage_urls().size(); i++) {
                        System.out.println("    " + (i + 1) + ". " + data.getImage_urls().get(i));
                    }
                }
            }
        }
        
        System.out.println("\n=== 测试完成 ===");
    }
} 